
//部门结构树
var dept_ztree;
var dept_setting = {
	data: {
		simpleData: {
			enable: true,
			idKey: "deptId",
			pIdKey: "parentId",
			rootPId: -1
		},
		key: {
			url:"nourl"
		}
	}
};

var vm = new Vue({
	el:'#rrapp',
	data:{
		empId:null,
		emp:{},
		works: [],
		rewards: [],
		pickerOptions: {
			disabledDate(time) {
				return time.getTime() > Date.now();
			}
		},
		politicalBackground: [{value: '群众'},{value:'团员'},{value:'预备党员'},{value:'党员'}],
		education: [{value:'大专'},{value:'本科'},{value:'硕士'},{value:'博士'}],
		statusType: [{value:'5',label:'不在岗'}],
		causes: [{value:'1',label:'请病假'},{value:'2',label:'停薪留职'}],
		fileList: [],
		timer: null,
        activeNames: ['1'],
		addEmp: {},
		changeEmpDept: [],
		changeEmpOffice: [],
		empStatusChange:[],
		statusChange: {},
		reverse: true,

	},
	created: function () {
		var url =document.location.toString();
		var arrObject=url.split("?");
		var arrPara=arrObject[1].split("=");
		this.empId=arrPara[1];
		this.getInfo();
		/*this.getWork();
		this.getReward();*/
		this.getAddEmp();
		this.getChangeEmpDept();
		this.getChangeEmpOffice();
		this.getEmpStatusChange();
		this.getStatusChange();
	},
	methods: {
		handleChange(val) {
			console.log(val);
		},
		getInfo: function(){
			$.get(baseURL + "fun/emp/info/"+this.empId, function(r){
				vm.emp = r.emp;
				vm.getDept();
			});
		},
		getWork: function(){
			$.get(baseURL + "fun/emp/work/"+this.empId, function(r){
				vm.works = r.work;
			});
		},
		getReward: function(){
			$.get(baseURL + "fun/emp/reward/"+this.empId, function(r){
				vm.rewards = r.reward;
			});
		},
		getAddEmp:function()
		{
			$.get(baseURL + "fun/emp/infoAddEmp/"+this.empId, function(r){
				vm.addEmp = r.addEmp;
			});
		},
		getChangeEmpDept:function()
		{
			$.get(baseURL + "fun/emp/infoChangeEmpDept/"+this.empId, function(r){
				vm.changeEmpDept = r.changeEmpDept;
			});
		},
		getChangeEmpOffice:function()
		{
			$.get(baseURL + "fun/emp/infoChangeEmpOffice/"+this.empId, function(r){
				vm.changeEmpOffice = r.changeEmpOffice;
			});
		},
		getStatusChange:function()
		{
			$.get(baseURL + "fun/emp/infoStatusChange/"+this.empId, function(r){
				vm.statusChange = r.statusChange;
			});
		},
		getEmpStatusChange:function()
		{
			$.get(baseURL + "fun/emp/infoEmpStatusChange/"+this.empId, function(r){
				vm.empStatusChange = r.empStatusChange;
			});
		},
		getDept: function(){
			//加载部门树
			$.get(baseURL + "sys/dept/list", function(r){
				dept_ztree = $.fn.zTree.init($("#deptTree"), dept_setting , r);
				var node = dept_ztree.getNodeByParam("deptId", vm.emp.deptId);
				if(node != null){
					dept_ztree.selectNode(node);
					vm.emp.deptName = node.name;
				}
			})
		},
	}
});
